import type { post_order_info_item_info } from '@/types/order'
import { uniRequset } from '@/utils/request'
import type { order_item_type } from '@/types/order'
import type { order_list_type } from '@/types/order'
export const createOrderApi = (post_order_info_item_info_list: post_order_info_item_info[]) => {
  return uniRequset<order_item_type[]>({
    url: '/order/create_order/',
    method: 'POST',
    data: post_order_info_item_info_list,
  })
}

export const get_order_infoApi = (order_number: string) => {
  return uniRequset<order_list_type[]>({
    url: `/order/get_orders_by_id/?order_number=${order_number}`,
    method: 'GET',
  })
}

export const getAllOrdersApi = (type: number, page: number) => {
  return uniRequset<order_list_type[]>({
    url: `/order/get_all_orders`,
    method: 'GET',
    data: { type, page },
  })
}

export const deleteOrderApi = (order_number: string) => {
  return uniRequset<order_list_type[]>({
    url: `/order/delete_order/?order_number=${order_number}`,
    method: 'DELETE',
  })
}
export const updateOrderApi = (order_number: string) => {
  return uniRequset({
    url: `/order/update_order/?order_number=${order_number}`,
    method: 'PUT',
  })
}
export const cancelOrderApi = (order_number: string) => {
  return uniRequset({
    url: `/order/cancel_order/?order_number=${order_number}`,
    method: 'DELETE',
  })
}
